<!--
*@Author: QWP
*@Description: 我的日程
*@Date: 2024-07-12 10:03:55
-->
<template>
  <a-layout class="f-h-100" >
    <a-layout-content>
      <Calender :data="calendarData"
        v-model:calendarType="calendarType"
        v-model:date="currentDate"
        :clickChangeMonth="true"
        @search="getSearch"
        @item-click="(data) => {
          test(data)
          currentId = data['keyid'];
          showAddS = true;
        }">
        <template #extra>
          <a-button type="primary" @click="toEdit">添加日程</a-button>
        </template>
      </Calender>
    </a-layout-content>
  </a-layout>

  <!-- 新增日程 -->
  <AddSchedule v-model:open="showAddS"
    width="100%"
    wrap-class-name="full-modal"
    :id="currentId"
    @close="currentId = '', showAddS = false"
    @success="showAddS = false, currentId = '', getSearch()"/>
</template>

<script lang='ts' setup>
import { ref, reactive, computed, onMounted } from 'vue' 
import { useRoute, useRouter } from 'vue-router'
import Month from './Month.vue'
import Calender from './Calender.vue'
import dayjs from 'dayjs';
import AddSchedule from '@/views/index/index/components/scheduleDetial/AddEchedule.vue'
import * as calendarApi from '@/service/assist/calendar'
import { useCalendarSearch } from './hook'

const year = ref<string>("2024年")

let showAddS = ref<boolean>(false)
const toEdit = () => {
  showAddS.value = true
}
let currentDate = ref<string>(dayjs().format('YYYY-MM-DD'))
const calendarData = ref<any[]>([])
const calendarType = ref<string>('month')
const dateValue = ref<string>(dayjs().format('YYYY-MM-DD'))
const currentId = ref<string>()

onMounted(()  => {
  getSearch()
})

// 查询日程信息
const getSearch = async () => {
  calendarData.value = await useCalendarSearch(calendarType.value, currentDate.value)
}

const test = (data) => {
  console.log("🚀 ~ test ~ data:", data)
  
}

defineExpose({
  toEdit
})
</script>

<style lang='scss' scoped>
</style>